package com.woniuxy.interceptors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: 马宇航
 * @Do: 拦截器配置类，之前的拦截器是使用的xml配置，现在必须用配置类的形式
 * @DateTime: 22/06/28/0028 下午 4:56
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class InterceptorRegister implements WebMvcConfigurer {

    @Autowired
    AuthInterceptor authInterceptor;
    /**
     *         <mvc:interceptor>
     *             <mvc:mapping path="/**"/>
     *             <bean class="com.woniuxy.utils.AuthInterceptor"/>
     *         </mvc:interceptor>
    */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //把我们自定义的拦截器注入到SpringMVC流程中。
        registry.addInterceptor(authInterceptor).addPathPatterns("/**");
    }
}
